package com.sm.service;

import com.sm.dao.DynamicCommentMapper;
import com.sm.model.DynamicComment;
import com.sm.model.User;
import com.sm.vo.FirstDynamicCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class DynamicCommentService {

    @Autowired
    private DynamicCommentMapper dynamicCommentMapper;
    @Autowired
    private UserService userService;

    public int commentDynamic(DynamicComment dynamicComment){
        int i = dynamicCommentMapper.commentDynamic(dynamicComment);
        return i;
    }

    public int selectUserNumber(Integer dynamicId){
        int i = dynamicCommentMapper.selectUserNumber(dynamicId);
        return i;
    }

  public List<DynamicComment> selectFirstDynamicCommentsById(Integer dynamicId){
       return dynamicCommentMapper.selectFirstDynamicById(dynamicId);
    }

    public DynamicComment selectById(Integer commentId){
        return dynamicCommentMapper.selectByPrimaryKey(commentId);
    }

    public FirstDynamicCommentVo selectSecondComments(Integer dynamicId,Integer fatherId,Integer topId){
        FirstDynamicCommentVo firstDynamicCommentVo = new FirstDynamicCommentVo();
        List<DynamicComment> dynamicComments = dynamicCommentMapper.selectSecondComments(dynamicId, fatherId,topId);
        firstDynamicCommentVo.setSecondComments(dynamicComments);
        return firstDynamicCommentVo;
    }
}
